package com.ftg.learn.bus.deptexam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ftg.learn.bus.deptexam.entity.DeptExam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface DeptExamMapper extends BaseMapper<DeptExam> {

    /**
     * 查经费表中审核状态为‘特殊情况’的数据车牌
     * @param expendcar_id
     * @return
     */
    @Select("select expendcar_id from sharecar_expendrecord_admin where check_state = '特殊情况';")
    String selectCarId(String expendcar_id);

    /**
     * 查一
     * @param deptexam_id
     * @return
     */
    @Select("select * from deptexam_admin d left join sharecar_expendrecord_admin s on d.expendcar_id = s.expendcar_id where deptexam_id = #{deptexam_id}")
    List<Map<String,Object>> findOne(String deptexam_id);

    /**
     * 查全部
     * @return
     */
    @Select("select * from deptexam_admin d left join sharecar_expendrecord_admin s on d.expendcar_id = s.expendcar_id")
    List<Map<String,Object>> showAll();

    /**
     * 添加公车经费表数据时将公车id填入
     * @param expendcar_id
     * @return
     */
    @Insert("insert into deptexam_admin (expendcar_id) VALUES (#{expendcar_id});")
    int insert(String expendcar_id);

    /**
     * 修改审核状态
     * @param check_state
     * @param expendcar_id
     * @return
     */
    @Update("update sharecar_expendrecord_admin set check_state = #{check_state} where expendcar_id = #{expendcar_id}")
    int update(String check_state,String expendcar_id);

    /**
     * 审批后在审批表中删除此条数据
     * @param deptexam_id
     * @return
     */
    @Delete("delete from deptexam_admin where deptexam_id = #{deptexam_id}")
    int delete(String deptexam_id);
}
